package com.dinner.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dinner.entity.DiOrder;
import com.dinner.entity.DiSeat;
import com.dinner.mapper.DiOrderMapper;
import com.dinner.mapper.DiSeatMapper;
import com.dinner.mapper.DiUserMapper;
import com.dinner.service.DiSeatService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dinner
 * @since 2022-02-13
 */
@Service
public class DiSeatServiceImpl extends ServiceImpl<DiSeatMapper, DiSeat> implements DiSeatService {
    @Autowired
    DiSeatMapper diSeatMapper;
    @Autowired
    DiUserMapper diUserMapper;
    @Autowired
    DiOrderMapper diOrderMapper;

    @Override
    public List<DiSeat> lookAll(int size, int current) {
        Page<DiSeat> page=new Page<>(size,current);
        Page<DiSeat> pages=diSeatMapper.selectPage(page,null);
        List<DiSeat> list=pages.getRecords();
        for(DiSeat a:list){
            if(a.getYdId()!=null){
                a.setDiUser(diUserMapper.selectById(a.getYdId()));
            }
            if(a.getDiOrder()!=null){
                a.setDiOrder(diOrderMapper.selectById(a.getOrderId()));
            }
        }
    return list;
    }
}
